package com.rocksdata.mc.ui.activity;

import android.os.Bundle;
import android.widget.TextView;

import com.ctz.commonframe.ui.TitleBarActivity;
import com.rocksdata.mc.business.BusinessManager;
import com.rocksdata.mc.entity.PreviewInfo;
import com.rocksdata.mc.R;
import com.rocksdata.mc.business.BusinessInterface;
import com.rocksdata.mc.entity.CourseInfo;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;

/**
 * Created by 陈堂正 on 2017/5/16.
 */
@ContentView(R.layout.activity_preview_detail)
public class PreviewDetailActivity extends TitleBarActivity {
    @ViewInject(R.id.tv_preview_content)
    private TextView tvPreviewContent;

    private CourseInfo courseInfo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        courseInfo = (CourseInfo) getIntent().getSerializableExtra("course_info");
        setTitleMiddleText("查看预习");
        setBackgroundColor(getResources().getColor(R.color.light_black));

        getPreview();
    }

    private void getPreview() {
        BusinessManager.getTimetableManager().getPreview(courseInfo, new BusinessInterface.OnBusinessResultListener() {
            @Override
            public void onBusinessResult(boolean isSuccess, Object object, String message) {
                if(isSuccess){
                    PreviewInfo info = (PreviewInfo) object;
                    tvPreviewContent.setText(info.getContent());
                }else{
                    tvPreviewContent.setText("没有预习");
                }
            }
        });
    }


}
